﻿@inherits System.Web.Mvc.WebViewPage<System.Int32?>
@if (Model.HasValue)
{ 
    @Html.TextBox("", (Model.Value), new { @class = "integerEditor" })
}
else
{
    @Html.TextBox("", "", new { @class = "integerEditor" })
    
}
<script type='text/javascript'>
    $(document).ready(function () {
        @{
            int MinValue = 0;
            int MaxValue = 100;
            foreach (var r in @ViewData.ModelMetadata.GetValidators(this.ViewContext))
            {
                if (r.GetType() == typeof(System.Web.Mvc.RangeAttributeAdapter))
                {
                    foreach (ModelClientValidationRule mcvr in ((System.Web.Mvc.RangeAttributeAdapter)r).GetClientValidationRules())
                    {
                        MinValue=(int)mcvr.ValidationParameters["min"];
                        MaxValue=(int)mcvr.ValidationParameters["max"];
                    }
                }
            }
        }
        var minValue = @MinValue;
        var maxValue = @MaxValue;
        $("#@ViewData.ModelMetadata.PropertyName").wijslider({
            min: minValue,
            max: maxValue,
            change: function (event, ui) {
                $("#@ViewData.ModelMetadata.PropertyName").val(ui.value);
            }
        });
    
    });
</script>
